import threading
import sys
class being_thread(threading.Thread):
	def __init__(self,beings):
		threading.Thread.__init__(self)
		self.beings = beings
		for being in self.beings:
			being.set_thread(self)
	def add_being(self,being):
		self.beings.append(being)
		being.set_thread(self)
	def remove_being(self,being):
		for i in range(len(self.beings)):
			if self.beings[i]==being:
				del self.beings[i]
				break
	def run(self):
		while True:
			for being in self.beings:
				try:
					being.move()
				except:
					print "Unexpected error:", sys.exc_info()[0]
					raise